package com.decorator.springcloud.controller;

import com.decorator.springcloud.entities.CommonResult;
import com.decorator.springcloud.entities.Payment;
import com.decorator.springcloud.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class PaymentController {

    @Autowired
    PaymentService paymentService;

    @PostMapping("/create")
    public CommonResult<?> create(@RequestBody Payment payment) {
        int i = paymentService.create(payment);
        if (i > 0) {
            return new CommonResult(200, "成功");
        }else {
            return new CommonResult(400, "失败！");
        }

    }   @GetMapping("/find/{id}")
    public CommonResult<?> create(@PathVariable String id) {
        Payment oneById = paymentService.findOneById(id);
        if (oneById !=null) {
            return new CommonResult(200, "成功",oneById);
        }else {
            return new CommonResult(400, "失败！");
        }

    }
}
